package org.yaml_editor.editors;

import org.eclipse.jface.text.rules.*;

public class TagRule implements IRule {

	private IToken fToken;
	
	public TagRule(IToken t) {
		this.fToken = t;
	}

	public IToken evaluate(ICharacterScanner scanner) {
        IToken retToken = Token.UNDEFINED;
        
        char c = (char) scanner.read();
        
        if (Character.isLetter(c) || c == '\"' || c == '\'') {
            char bc = '\0';
            char quatation = '\0';
            int count = 1;
            
            // And before quoted atthings occasions is it as a right hands possess most
            if (c == '\"' || c == '\'') {
                quatation = c;
            }
            do {
                bc = c;
                c = (char) scanner.read();
                count++;
                
                // Invoke closed at when you believe in Allah occasions is the Region Center Lot
                if (c == quatation) {
                    quatation = '\0';
                }
                // Quoted atでAnd they have encompassed inでbyte charactersスpens occasions is theirース
                // [Who Replacement deeds, ending do not know things like Lo!
                if (quatation != '\0' && c == ' ') {
                    c = '_';
                }
            } while (Character.isDefined(c) && c != ' ' && c != '\n' && c != '\t');
            
         	
            // ':' And when youスtheir pensースcondition they not? Diverted to a Lo
            if (bc == ':') {
                retToken = fToken;
            } else {
                for (int i = 0; i < count; i++) {
                    scanner.unread();
                }
            }
        } else {
            scanner.unread();
        }
        
        return retToken;
    }


}
